let app = getApp();
Page({
    data: {
        page: 0,
        size: 8,
        data: [],
        imageurl: app.globalData.imageurl,
        keyword: '',
        searching: true,
        hot: [],
        array: ['无锡', '锡山', '惠山', '滨湖', '梁溪', '新吴', '江阴', '宜兴'],
        index: 0,//默认显示位置
    },
    bindPickerChange: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
            index: e.detail.value
        })
    },
    onLoad: function () {
        for (let i = 0; i < getApp().globalData.config.length; i++) {
            if (getApp().globalData.config[i].key == 'pros') {
                this.setData({
                    pros: getApp().globalData.config[i]
                })
                break;
            }
        }
    },
    search: function () {
        console.log("222")
        let pros = this.data.pros;
        let keyword = this.data.keyword;
        let area = this.data.array[this.data.index];
        getApp().rq('/Index/getList', {
            typeid: pros.alis,
            sort: pros.sortname,
            keyword: keyword,
            area
        }).then(res => {
            this.setData({
                imageurl: getApp().globalData.imageurl,
                data: res.data,
                searching: false
            })
        })
    },
    productDetail: function (e) {
        swan.setStorageSync('prodetail', e.currentTarget.dataset.item);
        swan.navigateTo({
            url: '../productDetail/productDetail'
        });
    },

    bindkeyword: function (e) {
        this.setData({
            keyword: e.detail.value
        });
    },




});